<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$课堂练习$</title>
</head>
<body>
<script>
    //求数组中所有元素的和
    var arr = [10, 20, 30, 40, 50];
    var sum = 0;
    for (var i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    document.write(sum);
    document.write("<br />");

    //求数组中所有元素的平均值
    var arr1 = [1, 2, 3, 4, 5];
    var sum1 = 0;
    for (var i = 0; i < arr.length; i++) {
        sum1 += arr1[i];
    }
    document.write(sum1 / arr1.length);
    document.write("<br />");
    //求数组中所有元素中最大的值
    var arr2 = [1, 3, 2, 5, 10, 100, 500];
    var max = arr2[0];
    for (var i = 1; i < arr2.length; i++) {
        if (max < arr2[i]) {
            max = arr2[i];
        }
    }
    document.write("最大值：" + max);
    document.write("<br />");
    //求数组中所有元素的最小值
    var arr3 = [10, 20, 30, 40, 50];
    var min = arr3[0];
    for (var i = 0; i < arr3.length; i++) {
        if (min > arr3[i]) {
            min = arr3[i];
        }
    }
    document.write("最小值：" + min);
    document.write("<br />");
    //倒叙遍历数组
    // var arr4=[10,20,30,40,50,100];
    // for (var i =0;i<arr4.length;i++){
    //     document.write(arr4[i]);
    // }
    var arr4 = [10, 20, 30, 40, 50, 100];
    for (var i = arr4.length - 1; i >= 0; i--) {
        document.write(arr4[i]);
    }


</script>
</body>
</html>